//
//  IdeaCompleteViewController.m
//  OperationPro
//
//  Created by yaxue wang on 2017/1/17.
//  Copyright © 2017年 展鸿科技. All rights reserved.
//

#import "IdeaCompleteViewController.h"
#import "PollingDetailViewController.h"
#import "PollingCompleteTableViewController.h"
@interface IdeaCompleteViewController ()
@property(nonatomic,strong)NSString *textString;

@end

@implementation IdeaCompleteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.textString=@"";
    self.navBar.leftView = nil;
    [self.navBar setHidden:YES];
    UIView *narView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 64)];
    narView.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:narView];
    
    UIView *backView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 120, 64)];
    [narView addSubview:backView];
    [backView bk_whenTapped:^{
        UINavigationController *navcontroller = self.navigationController;
        NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:navcontroller.viewControllers];
        
        for (UIViewController *temp in viewControllers)
        {
            if ([temp isKindOfClass:[PollingDetailViewController class]])
            {
                [self.navigationController popToViewController:temp animated:YES];
            }
        }
    }];
    
    UIImage *icoBack = [UIImage imageNamed:@"Ico_nar_back"];
    UIImageView *imgBack = [[UIImageView alloc] initWithFrame:CGRectMake(15, 33, icoBack.size.width, icoBack.size.height)];
    imgBack.image=icoBack;
    [backView addSubview:imgBack];
    UILabel *backTitle = [[UILabel alloc] init];
    backTitle.frame=CGRectMake(CGRectGetMaxX(imgBack.frame) + 5, 20,70, 44);
    [backTitle setText:@"巡检详情"];
    [backTitle setTextColor:MainColor];
    [backTitle setFont:F(14)];
    [backView addSubview:backTitle];
    
    UILabel*titleLab =[[UILabel alloc]init];
    [narView addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(narView);
        make.top.equalTo(narView).offset(30);
    }];
    titleLab.font =F(16);
    titleLab.textColor =C(@"5a5a5a");
    titleLab.text=@"意见与建议";
  
    UIView *bottomLineView = [[UIView alloc] initWithFrame:CGRectMake(0, narView.bounds.size.height-.5, [UIScreen mainScreen].bounds.size.width, .5)];
    [bottomLineView setBackgroundColor:LineColor];
    [narView addSubview:bottomLineView];
    [CClass HttpRequestTask:YES withUrl:@"inspection_getSuggestion" withData:@{@"uuid":self.Uuid} notifyError:YES onSuccess:^(BaseModel *model) {
        if ([F_NSpace([model.B_data objectForKey:@"suggestion"]) isEqualToString:@""]) {
            [self createDetailWith:@"无内容"];
            self.textString=@"无内容";
            
        }else
        {
            [self createDetailWith:[model.B_data objectForKey:@"suggestion"]];
            self.textString=[model.B_data objectForKey:@"suggestion"];
            
        }
        
    } onError:^(BaseModel *model) {
        
    }];


}
-(void)createDetailWith:(NSString*)context
{
    
    NSString *contextString=context;
    CGSize  labelsize = [contextString sizeWithFont:F(11) constrainedToSize:CGSizeMake(WindowWidth-30, 900)];
    //完成的
    UIView *sucessView=[[UIView alloc]initWithFrame:CGRectMake(0, 74, WindowWidth, labelsize.height+30+90)];
    sucessView.backgroundColor=BackColor;
    [self.view addSubview:sucessView];
    UIView *centerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, sucessView.bounds.size.height-90)];
    centerView.backgroundColor=[UIColor whiteColor];
    [sucessView addSubview:centerView];
    UILabel *line3=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 0.5)];
    [centerView addSubview:line3];
    line3.backgroundColor=LineColor;
    UILabel *line4=[[UILabel alloc]initWithFrame:CGRectMake(0, centerView.bounds.size.height-0.5, WindowWidth, 0.5)];
    [centerView addSubview:line4];
    line4.backgroundColor=LineColor;
    UILabel *contextLab=[[UILabel alloc]initWithFrame:CGRectMake(15, 15, WindowWidth-30, centerView.bounds.size.height-30)];
    contextLab.text=contextString;
    contextLab.numberOfLines=0;
    contextLab.textColor=C(@"bdbdbd");
    contextLab.font=F(11);
    [centerView addSubview:contextLab];
    
    UIButton*editBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [sucessView addSubview:editBtn];
    editBtn.frame=CGRectMake(30, sucessView.bounds.size.height-65, WindowWidth-60, 30);
    [editBtn setBackgroundColor:MainColor];
    editBtn.layer.masksToBounds=YES;
    editBtn.layer.cornerRadius=6;
    editBtn.titleLabel.font=F(16);
    [editBtn setTitle:@"上一页" forState:UIControlStateNormal];
    [editBtn bk_addEventHandler:^(id sender) {
        PollingCompleteTableViewController *networkVC=[[PollingCompleteTableViewController alloc]init];
        networkVC.passDic=self.passDic;
        networkVC.allAr=self.allAr;
        networkVC.Uuid=self.Uuid;
        networkVC.unusalState=self.unusualState;
        [self pushController:networkVC Lever:0 Animated:NO];
        
        
    } forControlEvents:UIControlEventTouchUpInside];
    
    
}


@end
